package com.esproject.bean;

import com.esproject.Annonation.ESIndexField;
import org.apache.commons.lang.StringUtils;

import java.util.List;
import java.util.Set;

/**
 * Created by yan_li on 2017/2/18.
 */
public class CvInfo {
    @ESIndexField
    private String college;
    @ESIndexField
    private String cuid;
    @ESIndexField(id = true)
    private String cvid;
    @ESIndexField
    private String duration;
    @ESIndexField
    private String edu;
    @ESIndexField
    private String expJob;
    @ESIndexField
    private String expect_city;
    @ESIndexField
    private String leastcom;
    @ESIndexField
    private String leastjob;
    @ESIndexField
    private String major;
    @ESIndexField
    private String months;
    @ESIndexField
    private String name;
    @ESIndexField
    private int workTime;

    public String getCollege() {
        return college;
    }

    public void setCollege(String college) {
        this.college = college;
    }

    public String getCuid() {
        return cuid;
    }

    public void setCuid(String cuid) {
        this.cuid = cuid;
    }

    public String getCvid() {
        return cvid;
    }

    public void setCvid(String cvid) {
        this.cvid = cvid;
    }

    public String getDuration() {
        return duration;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public String getEdu() {
        return edu;
    }

    public void setEdu(String edu) {
        this.edu = edu;
    }

    public void setWorkTime(int workTime) {
        this.workTime = workTime;
    }

    public String getExpect_city() {
        return expect_city;
    }

    public void setExpect_city(String expect_city) {
        this.expect_city = expect_city;
    }

    public String getExpJob() {
        return expJob;
    }

    public void setExpJob(String expJob) {
        this.expJob = expJob;
    }

    public String getLeastcom() {
        return leastcom;
    }

    public void setLeastcom(String leastcom) {
        this.leastcom = leastcom;
    }

    public String getLeastjob() {
        return leastjob;
    }

    public void setLeastjob(String leastjob) {
        this.leastjob = leastjob;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public String getMonths() {
        return months;
    }

    public void setMonths(String months) {
        this.months = months;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getWorkTime() {
        return this.workTime;
    }

    public void setWorkTime(String months) {
        this.workTime = formatWorkTime(months);
    }

    public int formatWorkTime(String months){
        int year = 0;
        int monthsNum = 0;
        String monthYear = null;
        if (months.contains("年")) {
            String[] value = months.split("年");
            if (value == null || value.length < 2) {
                return 21;
            }
            String yearString = value[0];
            if (StringUtils.isNotBlank(yearString)) {
                year = Integer.valueOf(yearString);
            }
            monthYear = value[1];
        } else {
            monthYear = months;
        }
        if (StringUtils.isNotBlank(monthYear)) {
            String[] getValue = monthYear.split("个月");
            if (getValue != null) {
                monthsNum = Integer.valueOf(getValue[0]);
            }
        }
        return year * 12 + monthsNum;
    }
}
